package com.lv.service.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.lv.common.imp.OnPositionTListener
import com.lv.service.R
import com.lv.service.bean.CommonTab

/**
 * 作者： ygx
 * 创建日期：2022/6/24 8:10 PM
 * 签名： 天行健，君子以自强不息；地势坤，君子以厚德载物。
 *      _              _           _     _   ____  _             _ _
 *     / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 *    / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 *   / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 *  /_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 *
 * You never know what you can do until you try !
 * ----------------------------------------------------------------
 *
 */
class BookAddressAdapter(private val datas: MutableList<CommonTab>?) :
    BaseQuickAdapter<CommonTab, BaseViewHolder>
        (R.layout.item_address_text, datas) {

    override fun convert(holder: BaseViewHolder, item: CommonTab) {

        val layoutPosition = holder.layoutPosition
//                var clParent: ConstraintLayout = holder.getView<ConstraintLayout>(R.id.cl_parent)
        var tvName = holder.getView<TextView>(R.id.tv_name)
        tvName.text = item.name

        val isSelected = item.isSelcted
        tvName.setBackgroundResource(if (isSelected) com.lv.common.R.drawable.bg_line_eb613d_4 else 0)
        tvName.setTextColor(
            if (isSelected) context.resources.getColor(com.lv.common.R.color.color_EB613D) else context.resources.getColor(
                com.lv.common.R.color.color_242424
            )
        )

        tvName.setOnClickListener {
            mPositionListener?.onClick(layoutPosition, item.name)
        }


    }

    //公司条目
    var mPositionListener: OnPositionTListener<String>? = null

}